

import { _BasicDataSource } from '../_BasicDataSource'
import { uuid } from '../util';

import IconEntity from './IconEntity';
import PolylineEntity from './PolylineEntity'
import CircleEntity from './CircleEntity'
import RectangleEntity from './RectangleEntity'
import PolygonEntity from './PolygonEntity'
import SectorEntity from './SectorEntity'
import LabelEntity from './LabelEntity'
import AnnulusEntity from './AnnulusEntity'

const typeMapping = {
    icon: IconEntity,
    polyline: PolylineEntity,
    circle: CircleEntity,
    rectangle: RectangleEntity,
    polygon: PolygonEntity,
    sector: SectorEntity,
    label: LabelEntity,
    annulus: AnnulusEntity,
};


class ElementDataSource extends _BasicDataSource {
    constructor(parent, options = {}) {
        super(uuid(), parent, options);
        this.EntityTypeName = 'ElementEntity'
    }
    add(type, options) {
        if (typeMapping[type]) {
            var Entity = new typeMapping[type](options, this);
            this._Mapping[Entity.id] = Entity;
            this._Entities.add(Entity.Entity);
            return Entity;
        }
    }
}




export { ElementDataSource }